﻿//Created by Arcdemon//
//MapleCryptoAPI by aegisrunestone//
//Utilities class by aegisrunestone//
//Buffer class by aegisrunestone//
using System;
using System.Runtime.InteropServices;

// Login server for Maple Story EMU's.

namespace UtilityClass
{
    class Utils
    {
        [DllImport("kernel32.dll")]
        private static extern bool SetConsoleTextAttribute(IntPtr hConsoleOutput, int wAttributes);

        [DllImport("kernel32.dll")]
        private static extern IntPtr GetStdHandle(uint nStdHandle);

        public static bool SetConsoleColour(int Colour)
        {
            if (Colour == 0) return false;
            return SetConsoleTextAttribute(GetStdHandle(0xfffffff5), Colour);
        }

        public static void MoveBytes(byte[] Bytes, int Index)
        {
            for (int i = 0; i < Bytes.Length - (Index); i++)
            {
                Bytes[i] = Bytes[i + Index];
            }
        }

        public static byte[] ReplaceBytes(byte[] Bytes, int Index)
        {
            if ((Bytes.Length - Index) == 0) return new byte[1] { 00 };
            byte[] result = new byte[Bytes.Length - Index];
            System.Buffer.BlockCopy(Bytes, Index, result, 0, Bytes.Length - Index);
            return result;
        }

        public static void CopyBytes(byte[] Destination, byte[] Source)
        {
            System.Buffer.BlockCopy(Source, 0, Destination, 0, Source.Length);
        }

        public static void CopyBytes(byte[] Destination, byte[] Source, int Count)
        {
            System.Buffer.BlockCopy(Source, 0, Destination, 0, Count);
        }

        public static void CopyBytes(byte[] Destination, int DestinationIndex, byte[] Source, int SourceIndex, int Count)
        {
            System.Buffer.BlockCopy(Source, SourceIndex, Destination, DestinationIndex, Count);
        }

    }
}
//Created by Arcdemon//
//MapleCryptoAPI by aegisrunestone//
//Utilities class by aegisrunestone//
//Buffer class by aegisrunestone//